//
//  LogViewController.m
//  TT
//
//  Created by lanou3g on 16/3/11.
//  Copyright © 2016年 Super磊. All rights reserved.
//

#import "LogViewController.h"
#import <AVOSCloud/AVOSCloud.h>
#import "TTViewController.h"
#import "DrawerViewController.h"
#import "LeftMenuViewController.h"
#import "MessageViewController.h"
#import "AppDelegate.h"
#import <EaseMob.h>

@interface LogViewController ()
@property (weak, nonatomic) IBOutlet UITextField *TelPhone;
@property (weak, nonatomic) IBOutlet UITextField *passWord;
@property (weak, nonatomic) IBOutlet UIButton *Log;

@end

@implementation LogViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor =[UIColor lightGrayColor];
    [AVOSCloud setApplicationId:@"pLGUE2TepdIMn4pfjc9UOogY-gzGzoHsz" clientKey:@"Issl3J2BacCnbCCSk99vqs3K"];

}

//电话密码登入
- (IBAction)Login:(id)sender {
    
    [AVUser logInWithMobilePhoneNumberInBackground:self.TelPhone.text password:self.passWord.text block:^(AVUser *user, NSError *error) {
        if (error) {
            NSLog(@"%@",error);
        }
        else{
            NSLog(@"%@登陆成功",user);
            
            AppDelegate *app =[UIApplication sharedApplication].delegate;
            app.draw =[[DrawerViewController alloc]init];
            TTViewController *ttVC =[[TTViewController alloc]init];
            UINavigationController *naV =[[UINavigationController alloc]initWithRootViewController:ttVC];
            ttVC.mobilePhoneNumber = self.TelPhone.text;
            [app.draw setRootViewController:naV];
            //设置侧滑栏
            LeftMenuViewController *left =[LeftMenuViewController new];
            MessageViewController *right =[MessageViewController new];
            [app.draw setLeftVC:left];
            [app.draw setRightVC:right];
            [self presentViewController:app.draw animated:YES completion:nil];
//            [self.navigationController pushViewController:ttVC animated:YES];
        }
    }];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
